'''
class Car:

    def __init__(self, make, model, year):
        self.make = make
        self.model = model
        self.year = year
        self.odometer_reading = 0

    def get_descriptive_name(self):
        long_name = f"{self.year} {self.make} {self.model}"
        return long_name.title()

    def read_odometer(self):
        print(f"This car has {self.odometer_reading} miles on it.")

my_new_car = Car('audi','a4',2019)
my_new_car.odometer_reading = 23
my_new_car.read_odometer()
'''

#练习9-4
'''
class Restaurant:
    def __init__(self, name, type):
        self.name = name
        self.type = type
        self.number_served = 0

    def describe_restaurant(self):
        msg = f"{self.name}提供{self.type}"
        print(msg)

    def open_restaurant(self):
        print(f"{self.name}餐厅正常营业！")

    def set_number_served(self,number_served):
        self.number_served = number_served

    def increment_number_served(self,add_num):
        self.number_served += add_num

mango = Restaurant('白龙山食堂', '中式快餐')
mango.describe_restaurant()
mango.open_restaurant()
Restaurant('白龙山食堂', '中式快餐').describe_restaurant()
mango.number_served = 10
mango.set_number_served(16)
mango.increment_number_served(50)
print(mango.number_served)
'''

#9-5
class User:
    def __init__(self,first_name,last_name,email):
        self.first_name = first_name
        self.last_name = last_name
        self.email = email
        self.login_attempts = 0

    def describe_user(self):
        print(f"{self.first_name} {self.last_name}'s email is {self.email}")

    def greet_user(self):
        print(f"welecom to our web {self.first_name} {self.last_name}")

    def increment_login_attempts(self):
        self.login_attempts += 1

    def reset_login_attempts(self):
        self.login_attempts = 0

wjy = User('王','靖圆','wjy@e.com')
wjy.describe_user()
wjy.greet_user()

wjw = User('吴','家文','wjw@e.com')
wjw.describe_user()
wjw.greet_user()

wjw.increment_login_attempts()
wjw.increment_login_attempts()
wjw.increment_login_attempts()
print(wjw.login_attempts)
wjw.reset_login_attempts()
print(wjw.login_attempts)